package com.zhiwen.syc;

/**
 * @Auther: wuzhiwen
 * @Date: 2018/12/21 10:04
 * @Description:
 */
public class SycDemo {
    public static void main(String[] args) {
        final Demo demo = new Demo();
        new Thread(new Runnable() {
            public void run() {
                try {
                    demo.getOne();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(new Runnable() {
            public void run() {
                demo.getTwo();
            }
        }).start();
    }
}

class Demo {

    public static synchronized void getOne() throws InterruptedException {
        Thread.sleep(1000);
        System.out.println("one");
    }

    public synchronized void getTwo() {
        System.out.println("two");
    }

}